package chat.user;

import java.io.Serializable;
import java.net.Socket;

public class User implements Serializable, Cloneable {

	private static final long serialVersionUID = 1L;
	private String user_name, DOB;
	private Socket socket;
	private String relatedGroup = null;
	private String status = "ONLINE";
	private int SocketID;
	
	public User(){
		
		
	}
	
	public User(boolean RootUser){
		
		if (RootUser){
			
			relatedGroup = "General";
		}
		
	}
	public User(Socket s, String g){
		
		this.socket = s;
		
		this.relatedGroup = g;
	}
	
	public void setUserName(String name){
		
		user_name=name;
	}
	
	public void addSocket(Socket s){
		
		socket = s;
		
	}
	public Socket getSocket(){
		
		return this.socket;
		
	}
	public void removeSocket(){
		
		this.socket = null;
	}
	public String getRelatedGroup(){
		return this.relatedGroup;
	}
	public String getUserName(){
		
		return this.user_name;
		
	}
	
	public void updateRelatedGroup(String g){
		
		this.relatedGroup = g;
	}
	
	public boolean equals(User u){
		
		if (this.user_name.equalsIgnoreCase(u.getUserName())){
			
			return true;
		}
		
		return false;
	}
	
	public String changeStatus(String newStatus){
		return this.status = newStatus;
	}
	
	public String getStatus(){
		return this.status;
	}
	
	public void setStatus(String status){
		this.status = status;
	}
	
	@Override
	public Object clone() {

		try {

			return super.clone();

		} catch (CloneNotSupportedException e) {

			throw new AssertionError("Clone Not Supported Error");

		}

	}

	public int getSocketID(){
		return this.SocketID;
	}
	public void setSocketID(int SocketID){
		this.SocketID = SocketID;
	}
}
